﻿//  --------------------------------
//  Copyright (c) AW Systems, Inc. All rights reserved.
//  This source code is made available under the terms of the Microsoft Public License (Ms-PL)
//  http://www.codeplex.com/SLAM/license
//  ---------------------------------

using AWS.SLAM.Events;
using AWS.SLAM.StructureMap;
using StructureMap.Configuration.DSL;
using AWS.SLAM.Activation;

namespace AWS.SLAM.Hierarchy
{
	/// <summary>
	/// HierarchicalListTypeProfile defines the dependencies necessary for SLAM to
	/// process Lists using the HierarchyPositionField and to hierarchically store
	/// List Items in a List configured to be managed by SLAM.
	/// </summary>
	public class HierarchicalListTypeProfile : ITypeProfile
	{
		#region ITypeProfile Members

		/// <summary>
		/// Sets new dependencies in StructureMap for SLAM's IItemCreator, IItemDeleter, and IItemUpdater
		/// as a Profile with the given name to handle hierarchical Lists.
		/// </summary>
		/// <param name="registry"></param>
		/// <param name="name"></param>
		public void CreateProfile(Registry registry, string name)
		{
			registry.Profile(name, p => p.For<IItemCreator>().Use<HierarchicalListItemCreator>());
			registry.Profile(name, p => p.For<IItemDeleter>().Use<HierarchicalListItemDeleter>());
			registry.Profile(name, p => p.For<IItemUpdater>().Use<HierarchicalListItemUpdater>());
			registry.Profile(name, p => p.For<IDataSynchronizeTypeProcessor>().Use<HierarchyDataSynchronizeTypeProcessor>());

			//registry.CreateProfile(name).
			//    For<IItemCreator>().UseConcreteType<HierarchicalListItemCreator>().
			//    For<IItemDeleter>().UseConcreteType<HierarchicalListItemDeleter>().
			//    For<IItemUpdater>().UseConcreteType<HierarchicalListItemUpdater>().
			//    For<IDataSynchronizeTypeProcessor>().UseConcreteType<HierarchyDataSynchronizeTypeProcessor>();
		}

		#endregion

	}
}
